﻿<%@ Page Language="C#" MasterPageFile="~/Game/Game.Master" AutoEventWireup="true" CodeBehind="News.aspx.cs" Inherits="smallDeimos.Game.News" Title="Small Deimos - News" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" Height="201px" Width="849px" 
        DataKeyNames="NewsID" onrowdatabound="GridView1_RowDataBound">
        <Columns>
            <asp:BoundField DataField="Time" HeaderText="Date" SortExpression="Time">
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
            </asp:BoundField>
            <asp:BoundField DataField="Message" HeaderText="Message" 
                SortExpression="Message" HtmlEncode="False">
                <ItemStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:CommandField ShowDeleteButton="True">
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" />
            </asp:CommandField>
        </Columns>
        <EmptyDataTemplate>
            No news sorry.
        </EmptyDataTemplate>
    </asp:GridView>
    <left>    <asp:Button ID="Button1" runat="server" Text="Remove all news" 
        onclick="Button1_Click" />
</left>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:smallDeimosConnectionString %>" 
        SelectCommand="SELECT NewsID, PlayerId, DATEADD(hour, (SELECT TimeZone FROM Players WHERE (PlayerId = @PlayerId)), Date) AS Time, Message FROM News WHERE (PlayerId = @PlayerId) ORDER BY Time DESC" 
        DeleteCommand="Delete from News Where NewsId = @NewsId">
        <SelectParameters>
            <asp:CookieParameter CookieName="sd_id" Name="PlayerId" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="NewsId" />
        </DeleteParameters>
    </asp:SqlDataSource>
</asp:Content>
